<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="jasmine-3.1.0/jasmine.css">

</head>
<script type="text/javascript" src="jasmine-standalone-3.1.0/lib/jasmine-3.1.0/jasmine-html.js"></script>
<script type="text/javascript" src="jasmine-standalone-3.1.0/lib/jasmine-3.1.0/jasmine.js"></script>
<script type="text/javascript" src="jasmine-standalone-3.1.0/lib/jasmine-3.1.0/boot.js"></script>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">
	function get1() {
		$.getJSON("http://localhost:8888/test/get1").then(
				function(result){
					console.log(result);
				});
	}
	jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
	
	var base="http://localhost:8888/test";
	describe("ajax跨域问题",function(){
		//测试方法
		it("get1 请求",function(done){
			var result;
			
			$.getJSON(base+"/get1").then(
					function(json){
						result = json;
					});
			setTimeout(function(){
				expect(result).toEqual({
					"data":"get1 ok"
				});	
				done;
			},100);
		});
	});
	function jsonp() {
		$.ajax({
			url:base+"/get1",
			dataType:"jsonp",
			success:function(data){
				console.log(data);
			}
		});
	}
	function getcookie() {
		$.ajax({
			url:base+"/getcookie",
			xhrFields:{
				withCredentials:true
			},
			success:function(data){
				console.log(data);
			}
		});
	}
</script>
<body>
<a href="#" onclick="get1()">发送get1请求</a><br/>
<a href="#" onclick="jsonp()">发送jsonp请求</a><br/>
<a href="#" onclick="getcookie()">发送cookie请求</a><br/>
</body>
</html>